<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <meta http-Equiv="Expires" Content="0" />
    <title>监控列表</title>
    <link rel="stylesheet" href="/lib/layui/css/layui.css"/>
</head>

<body>
<div id="ccc">


</div>
<script src="/lib/layui/layui.all.js"></script>
<script src="/lib/jquery.min.js"></script>
<script src="/lib/vue.min.js"></script>
<script src="/lib/store.min.js"></script>
<script type="text/javascript">


var path = 'localhost:8081/'; 
var userId = 'lys'; 
//"signCode_monitor_type_longtime"
var userCode = userId+"_AAA"; 
var websocket; 
if ('WebSocket' in window) { 
  websocket = new WebSocket("ws://" + path + "wsz?userCode=" + userCode); 
} else if ('MozWebSocket' in window) { 
  websocket = new MozWebSocket("ws://" + path + "wsz?userCode=" + userCode); 
} else { 
  websocket = new SockJS("http://" + path + "wsz/sockjs?userCode=" + userCode); 
} 
websocket.onopen = function(event) { 
  console.log("WebSocket:已连接"); 
  console.log(event); 
}; 
websocket.onmessage = function(event) { 
  var data = JSON.parse(event.data); 
  console.log("WebSocket:收到一条消息-norm", data); 
  $("#ccc").append(data+"\n");
 // alert("WebSocket:收到一条消息"); 
}; 
websocket.onerror = function(event) { 
  console.log("WebSocket:发生错误 "); 
  console.log(event); 
}; 
websocket.onclose = function(event) { 
  console.log("WebSocket:已关闭"); 
  console.log(event); 
}

</script>
</body>
</html>